﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace GenericControlsWinForm
{
    public class CommomValidator
    {
        public static bool KeyIsNumber(Keys key)
        {
            return (key >= Keys.D0 && key <= Keys.D9) || (key >= Keys.NumPad0 && key <= Keys.NumPad9);
        }

        public static bool KeyIsDecimalNumber(Keys key)
        {
            return (key >= Keys.D0 && key <= Keys.D9) || (key >= Keys.NumPad0 && key <= Keys.NumPad9) || key == Keys.Decimal;
        }

        public static bool KeyIsNumber(int key)
        {
            return (key >= 49 && key <= 57) || (key >= 96 && key <= 105);
        }

        public static bool KeyIsDecimalNumber(int key)
        {
            return (key >= 49 && key <= 57) || (key >= 96 && key <= 105) || key == 110;
        }

        public static bool CharIsNumber(char key)
        {
            return char.IsNumber(key) || ((Keys)key) == Keys.Back;
        }

        public static bool CharIsDecimalNumber(char key)
        {
            return char.IsNumber(key) || ((Keys)key) == Keys.Back || key.Equals(',');
        }
    }
}
